//
//  JFEmojiInputViewCell.m
//
//  Created by ilongge on 2020/8/4.
//

#import "XLEmojiInputViewCell.h"
#import "XLEmojiManager.h"

@interface XLEmojiInputViewCell()
@property (nonatomic, strong) UIImageView *emoji;
@end
@implementation XLEmojiInputViewCell
+ (instancetype)emojiInputViewCellWith:(UICollectionView *)collection at:(NSIndexPath *)indexPath{
    
    XLEmojiInputViewCell *cell = [collection dequeueReusableCellWithReuseIdentifier:[[self class] description]
                                                                       forIndexPath:indexPath];
    
    return cell;
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self.contentView addSubview:self.emoji];
        self.contentView.backgroundColor = UIColor.whiteColor;
        self.contentView.layer.cornerRadius = 4;
    }
    return self;
}
- (void)configCellWithEmojiName:(NSString *)emojiName {
    self.emoji.image = [XLEmojiManager JFLiveEmojiImageWithName:emojiName];
    self.emoji.frame = CGRectMake(0, 0, 28, 28);
}

- (void)layoutSubviews{
    self.emoji.center = self.contentView.center;
}

- (UIImageView *)emoji{
    if (_emoji == nil) {
        _emoji = [[UIImageView alloc] init];
        _emoji.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _emoji;
}

@end
